<?php $this->display(tpl('head',true)); ?>
<style>
	.layui-form-label {
	    float: left;
	    display: block;
	    padding: 9px 15px;
	    width: 10%;
	    font-weight: 400;
	    text-align: right;
	}
	.layui-input, .layui-textarea {
	    display:  inline;
	    width: 80%;
	    padding-left: 10px;
	}
</style>
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	  	<legend>回复微信用户关键字内容设置</legend>
	</fieldset>
	<form class="layui-form"  method="post">
		<table class="layui-table">
			<tbody>
				<tr>
					<td width="200">关键词：</td>
					<td>
						<input name="add[title]" value="<?php echo $data['title'] ?>"  placeholder="关键词" class="layui-input" type="text">
					</td>
				</tr>
				<tr>
					<td width="200">图片：</td>
					<td>
						<input name="add[picurl]" id="pic" value="<?php echo $data['picurl'] ?>"   placeholder="请点击右侧上传图片，仅支持jpg和png" class="layui-input picurl" type="text">
						<button type="button" class="layui-btn layui-btn-normal picurlbutton" id="select_pic">选择图片上传</button>
					</td>
				</tr>
				<tr>
					<td width="200">链接：</td> 
					<td>
						<input name="add[url]" value="<?php echo $data['url'] ?>"  placeholder="请输入完整网址" class="layui-input" type="text">
					</td>
				</tr>
				<tr>
					<td width="200">回复的内容：</td>
					<td>
						<textarea class="layui-textarea" placeholder="描述内容" name="add[description]"><?php echo $data['description'] ?></textarea>
					</td>
				</tr>
			</tbody>
		</table>
		<div class="layui-form-item">
			<div class="layui-input-block my_button">
				<input type="hidden" name="step" value="post" />
				<input type="hidden" name="id" id="id" value="<?php echo  $data['id'] ?>" />
				<button class="layui-btn">立即设置</button>
			</div>
		</div>
	</form>
	<blockquote class="layui-elem-quote layui-text">
		<li>1、这里可以设置类似机器人回复微信用户提出的问题，你可以设置关键词，根据用户提出的问题中包含此关键字时，就回复对应的内容。回答不上的内容，就发给客服回复.</li>
		<li>2、排在最前面的会优先匹配。</li>
		<li>2、如果想回复图文消息，4项必填缺一不可。</li>
	</blockquote>
<?php if(!$_GET['id']){ ?>	
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	  	<legend>关键字列表</legend>
	</fieldset>
	<table class="layui-table">
		<thead>
			<tr>
				<td width="200">关键词：</td>
				<td>回复内容</td>
				<td width="150" align="center">操作</td>
			</tr>
		</thead>
		<tbody>
		<?php foreach($dataDB AS $row){		?>	
			<tr>
				<td width="100"><?php echo $row['title'] ?></td>
				<td>
					<?php if($row['picurl']){ ?>
						<table class="layui-table">
							<tbody>
								<tr>
								    <td rowspan="2" width="15%"><a href="<?php echo get_img_url($row['picurl']) ?>" target="_blank"><img width="100" height="60" src="<?php echo get_img_url($row['picurl']) ?>" ></a></td>
								    <td width="10%">链接：</td>
								    <td><?php echo $row['url'] ?></td>
								</tr>
								<tr>
								    <td colspan="2"><?php echo $row['description'] ?></td>
								</tr>
							</tbody>
						</table>
					<?php }else{ echo $row['description'] ; }?>
				</td>
				<td width="150" align="center">
					<a href="<?php echo PLUGIN_ACTION ?>reply/setting/id_<?php echo $row['id']?>" class="layui-btn layui-btn-sm">编辑</a>
					<a href="<?php echo PLUGIN_ACTION ?>reply/del/id_<?php echo $row['id']?>"  class="layui-btn layui-btn-sm layui-btn-danger">删除</a>
				</td>
			</tr>
		<?php } ?>
		</tbody>
	</table>
	<div class="page">
		<?php echo $Get_Page ?>
	</div>
<?php } ?>
<script>

layui.config({
	version: '<?php echo NOWTIME ?>'
});
layui.use(['form','table', 'upload'], function(){
  	var $ = layui.jquery,table=layui.table;
	var form = layui.form;
	upload = layui.upload;
	upload.render({
	    elem: '#select_pic',
	    url: '/admin/upfile/up',
	    auto: true,
	    exts:'jpg|png',
	    before: function(obj){
	    	files = obj.pushFile(); //将每次选择的文件追加到文件队列
	    	loading = layer.load();
	    },
	    done: function(res, index, upload){
	    	layer.close(loading);
		    if(res.Result==0){
		    	layer.msg(res.content);
		    }else{
		      	$('#pic').val(res.url); 
		    }
		    delete files[index]; //删除对应的文件
	    }
	});
});
	


</script>
<?php $this->display(tpl('foot',true)); ?>